<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<title>Insert title here</title>
</head>
<style>
#see{
width: 235px;
    height: 200px;
    float: left;
    position: relative;
    color: white;
    left: 651px;
    background: black;
    z-index: 2;
    display: none;}
.title{
text-align: center;
}
#look{
display:table;
width: 150px;
    height: 120px;
    position: relative;
    margin: auto;
    top: 20px;
    text-align: center;
    }
    #kkk{
    display:table-cell;
    vertical-align: middle;
    }
    #write{
        position: relative;
    height: 42px;
    width: 64px;
    font-size: 28px;
   
    margin: auto;
    top: -42px;
    cursor: pointer;}
#table{
	margin: auto;
    top: 120px;
     position: relative;
    }
    .eid{
    text-align: center;
    }
    #receive{
     left: 105px;
    position: relative;
    top: 20px;

    }
    #back{
    position: relative;
    left: 85px;
    top: 8px;
    cursor: pointer;}
    #fajian{
    position: relative;
    left: 8px;
    top: 8px;}

</style>
<script>
$(function(){
	$('button').click(function(){
		console.log($(this).val());
		$.ajax({
			url : '${pageContext.request.contextPath}/judge/email',
			type : 'post',
			dataType : 'json',
			data : {
				'eid' : $(this).val(),
			},
			success:function(data){
				console.log(data);
				
				var str="<span id='fajian'>发件人："+data[0].sendEmail+"</span>"
				+"<span id='back'>返回</span>"
				+"<div id='look'><span id='kkk'>"+data[0].content+"</span></div>"
				+"<span id='receive'>收件人："+data[0].receive+"</span>";
				$("#see").html(str);
				$("#see").css("display","block");
			}
		})
	})
		
	
	$('body').on("click",'#back',function(){
		$("#see").css("display","none");
	})
	
	$("#write").click(function(){
		$("#tijiao").submit();
	})
})
</script>
<body>
	<c:if test="${sessionScope.email==null }">
		<table border='1'>
			<tr>
				<th>状态</th>
				<th>主题</th>
				<th>时间</th>
				<th>刪/留</th>
			</tr>
			<tr>
				
			</tr>
		</table>
	</c:if>
	<c:if test="${sessionScope.email!=null}">
		<table border='1' id='table'>
			<tr>
				<th>邮件编号</th>
				<th>状态</th>
				<th>主题</th>
				<th>时间</th>
				<th>刪/查</th>
			</tr>
			<c:forEach items='${ sessionScope.email}' var='email'>
				<tr>
					<td class='eid'>${email.eid}</td>
					<td>&nbsp已读&nbsp</td>
					<td class='title'>${email.etitle}</td>
					<td>${email.e_time}</td>
					<td>&nbsp<button value='${email.eid}'>删除</button>&nbsp<button value='${email.eid}'>查看</button>&nbsp</td>
				</tr>
			</c:forEach>
			
		</table>
	</c:if>
	<div id='see'>
		<span id='fajian'>发件人：</span><span id='back'>返回</span>
		<div id='look'>
		<span id='kkk'>爱上大家洼的交往等级我加上降低及爱我ID窘境的骄傲我</span>
		</div>
		<span id='receive'>收件人：</span>
	</div>
	<div id='write'><form action='${pageContext.request.contextPath}/first/write' id='tijiao'>写信
	<input type='hidden' name='username' value='${sessionScope.email[0].e_username}'>
	</form></div>
</body>
</html>